#!/bin/bash

APP=edu

if [ -n "$2" ] ;then
   do_date=$2
else 
   echo "请传入日期参数"
   exit
fi 



ads_user_change="
insert overwrite table $APP.ads_user_change
select * from $APP.ads_user_change
union
select
    churn.dt,
    user_churn_count,
    user_back_count
from
(
    select
        '$do_date' dt,
        count(*) user_churn_count
    from $APP.dws_user_user_login_td
    where dt='$do_date'
    and login_date_last=date_add('$do_date',-7)
)churn
join
(
    select
        '$do_date' dt,
        count(*) user_back_count
    from
    (
        select
            user_id,
            login_date_last
        from $APP.dws_user_user_login_td
        where dt='$do_date'
    )t1
    join
    (
        select
            user_id,
            login_date_last login_date_previous
        from $APP.dws_user_user_login_td
        where dt=date_add('$do_date',-1)
    )t2
    on t1.user_id=t2.user_id
    where datediff(login_date_last,login_date_previous)>=8
)back
on churn.dt=back.dt;


"
ads_user_retention="
insert overwrite table $APP.ads_user_retention
select * from $APP.ads_user_retention
union
select
    '$do_date' dt,
    login_date_first create_date,
    datediff('$do_date',login_date_first) retention_day,
    sum(if(login_date_last='$do_date',1,0)) retention_count,
    count(*) new_user_count,
    cast(sum(if(login_date_last='$do_date',1,0))/count(*)*100 as decimal(16,2)) retention_rate
from
(
    select
        user_id,
        date_id login_date_first
    from edu.dwd_user_register_inc
    where dt>=date_add('$do_date',-7)
    and dt<'$do_date'
)t1
join
(
    select
        user_id,
        login_date_last
    from $APP.dws_user_user_login_td
    where dt='$do_date'
)t2
on t1.user_id=t2.user_id
group by login_date_first;



"
ads_user_stats="
insert overwrite table $APP.ads_user_stats
select * from $APP.ads_user_stats
union
select
    '$do_date' dt,
    t1.recent_days,
    new_user_count,
    active_user_count
from
(
    select
        recent_days,
        sum(if(login_date_last>=date_add('$do_date',-recent_days+1),1,0)) new_user_count
    from $APP.dws_user_user_login_td lateral view explode(array(1,7,30)) tmp as recent_days
    where dt='$do_date'
    group by recent_days
)t1
join
(
    select
        recent_days,
        sum(if(date_id>=date_add('$do_date',-recent_days+1),1,0)) active_user_count
    from edu.dwd_user_register_inc lateral view explode(array(1,7,30)) tmp as recent_days
    group by recent_days
)t2
on t1.recent_days=t2.recent_days;




"
ads_user_action="

insert overwrite table $APP.ads_user_action
select * from $APP.ads_user_action
union
select
    '$do_date' dt,
    page.recent_days,
    home_count,
    good_detail_count,
    cart_count,
    order_count,
    payment_count
from
(
    select
        1 recent_days,
        sum(if(page_id='home',1,0)) home_count,
        sum(if(page_id='good_detail',1,0)) good_detail_count
    from $APP.dws_traffic_page_visitor_page_view_1d
    where dt='$do_date'
    and page_id in ('home','good_detail')
    union all
    select
        recent_days,
        sum(if(page_id='home' and view_count>0,1,0)),
        sum(if(page_id='good_detail' and view_count>0,1,0))
    from
    (
        select
            recent_days,
            page_id,
            case recent_days
                when 7 then view_count_7d
                when 30 then view_count_30d
            end view_count
        from $APP.dws_traffic_page_visitor_page_view_nd lateral view explode(array(7,30)) tmp as recent_days
        where dt='$do_date'
        and page_id in ('home','good_detail')
    )t1
    group by recent_days
)page
join
(
    select
        1 recent_days,
        count(*) cart_count
    from $APP.dws_trade_user_cart_add_1d
    where dt='$do_date'
    union all
    select
        recent_days,
        sum(if(cart_count>0,1,0))
    from
    (
        select
            recent_days,
            case recent_days
                when 7 then cart_add_count_7d
                when 30 then cart_add_count_30d
            end cart_count
        from $APP.dws_trade_user_cart_add_nd lateral view explode(array(7,30)) tmp as recent_days
        where dt='$do_date'
    )t1
    group by recent_days
)cart
on page.recent_days=cart.recent_days
join
(
    select
        1 recent_days,
        count(*) order_count
    from $APP.dws_trade_user_order_1d
    where dt='$do_date'
    union all
    select
        recent_days,
        sum(if(order_count>0,1,0))
    from
    (
        select
            recent_days,
            case recent_days
                when 7 then order_count_7d
                when 30 then order_count_30d
            end order_count
        from $APP.dws_trade_user_order_nd lateral view explode(array(7,30)) tmp as recent_days
        where dt='$do_date'
    )t1
    group by recent_days
)ord
on page.recent_days=ord.recent_days
join
(
    select
        1 recent_days,
        count(*) payment_count
    from $APP.dws_trade_user_payment_1d
    where dt='$do_date'
    union all
    select
        recent_days,
        sum(if(order_count>0,1,0))
    from
    (
        select
            recent_days,
            case recent_days
                when 7 then payment_count_7d
                when 30 then payment_count_30d
            end order_count
        from $APP.dws_trade_user_payment_nd lateral view explode(array(7,30)) tmp as recent_days
        where dt='$do_date'
    )t1
    group by recent_days
)pay
on page.recent_days=pay.recent_days;


"

ads_new_buyer_stats="



insert overwrite table $APP.ads_new_buyer_stats
select * from $APP.ads_new_buyer_stats
union
select
    '$do_date',
    odr.recent_days,
    new_order_user_count,
    new_payment_user_count
from
(
    select
        recent_days,
        sum(if(order_date_first>=date_add('$do_date',-recent_days+1),1,0)) new_order_user_count
    from $APP.dws_trade_user_order_td lateral view explode(array(1,7,30)) tmp as recent_days
    where dt='$do_date'
    group by recent_days
)odr
join
(
    select
        recent_days,
        sum(if(payment_date_first>=date_add('$do_date',-recent_days+1),1,0)) new_payment_user_count
    from $APP.dws_trade_user_payment_td lateral view explode(array(1,7,30)) tmp as recent_days
    where dt='$do_date'
    group by recent_days
)pay
on odr.recent_days=pay.recent_days;

"





ads_traffic_stats_by_source="
insert overwrite table $APP.ads_traffic_stats_by_source
select * from $APP.ads_traffic_stats_by_source
union
select
    '$do_date' dt,
    recent_days,
    sc,
    source,
    cast(count(distinct(mid_id)) as bigint) uv_count,
    cast(avg(during_time_1d)/1000 as bigint) avg_duration_sec,
    cast(avg(page_count_1d) as bigint) avg_page_count,
    cast(count(*) as bigint) sv_count,
    cast(sum(if(page_count_1d=1,1,0))/count(*) as decimal(16,2)) bounce_rate
from $APP.dws_traffic_session_page_view_1d lateral view explode(array(1,7,30)) tmp as recent_days
where dt>=date_sub('$do_date',recent_days-1)
group by recent_days,sc,source;
"
ads_page_path="
insert overwrite table $APP.ads_page_path
select * from $APP.ads_page_path
union
select
    '$do_date' dt,
    source_id,
    nvl(t2.target_id,'null'),
    count(*) path_count
from
(
    select
        concat('step-',rn,':',page_id) source_id,
        concat('step-',rn+1,':',next_page_id) target_id
    from
    (
        select
            page_id,
            lead(page_id,1,null) over(partition by session_id order by view_time) next_page_id,
            row_number() over (partition by session_id order by view_time) rn
        from $APP.dwd_traffic_page_view_inc
        where dt='$do_date'
    )t1
)t2
group by t2.source_id,t2.target_id;
"
ads_source_ordersum="
insert overwrite table $APP.ads_source_ordersum
select '$do_date' dt,
       recent_days,
       sc,
       source_name,
       sum(user_order_sum)/sum(user_sum) order_stay_per,
       sum(order_sum) user_order
from (
    select sc,
           user_sum,
           user_order_sum,
           order_sum,
           dt,
           source_name
    from
    $APP.dws_traffic_source_ordersum_1d ds
    left join (
        select id,
               source source_name
        from $APP.ods_base_source_full
        where dt = '$do_date'
        ) s
        on s.id = sc
        ) t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt>=date_sub('$do_date',recent_days-1)
group by recent_days,sc,source_name;
"
ads_age_order="
insert overwrite table $APP.ads_age_order
select
'$do_date' dt,
recent_days,
age_group,
sum(order_ct) order_ct
from $APP.dws_age_group_order_1d
lateral view explode(array(1,7,30)) tmp as recent_days
where dt>=date_sub('$do_date',recent_days-1)
group by age_group, recent_days;
"
ads_category_order="
insert overwrite table $APP.ads_category_order
select '$do_date' dt,
        category_id,
        category_name,
       recent_days,
       sum(order_count_1d) order_count,
       sum(order_person_count_1d) order_person_count,
       sum(order_amounts_1d) order_amounts
from
(select dc.category_id,
        category_name,
        order_count_1d,
        order_person_count_1d,
        order_amounts_1d,
        dt
from $APP.dws_course_order_category_1d dc
left join (
    select category_id,
           category_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by category_id, category_name
    )dim
on dc.category_id = dim.category_id
    )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by category_id, category_name, recent_days;
"
ads_subject_order="
insert overwrite table $APP.ads_subject_order
select '$do_date' dt,
        subject_id,
        subject_name,
       recent_days,
       sum(order_count_1d) order_count,
       sum(order_person_count_1d) order_person_count,
       sum(order_amounts_1d) order_amounts
from
(select dc.subject_id,
        subject_name,
        order_count_1d,
        order_person_count_1d,
        order_amounts_1d,
        dt
from $APP.dws_course_order_category_1d dc
left join (
    select subject_id,
           subject_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by subject_id, subject_name
    )dim
on dc.subject_id = dim.subject_id
    )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by subject_id, subject_name, recent_days;
"
ads_course_order="
insert overwrite table $APP.ads_course_order
select '$do_date' dt,
        course_id,
        course_name,
       recent_days,
       sum(order_count_1d) order_count,
       sum(order_person_count_1d) order_person_count,
       sum(order_amounts_1d) order_amounts
from
(select dc.course_id,
        course_name,
        order_count_1d,
        order_person_count_1d,
        order_amounts_1d,
        dt
from $APP.dws_course_order_category_1d dc
left join (
    select id,
           course_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by id, course_name
    )dim
on dc.course_id = dim.id
    )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by course_id, course_name, recent_days;
"
ads_process_user_review_by_course="
insert overwrite table $APP.ads_process_user_review_by_course
select '$do_date' dt,
       course_id,
       course_name,
       recent_days,
       avg(positiveratings1) positiveratings,
       sum(reviewnum1) reviewnum,
       avg(avgreview1) avgreview
from
(select course_id,
       course_name,
       positiveratings1,
       reviewnum1,
       avgreview1,
       dt
from $APP.dws_process_user_course_review_1d dp
left join (
    select id,
           course_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by id, course_name
    )dim
on dp.course_id = dim.id
    ) t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by course_id, course_name, recent_days;
"
ads_category_retention="
insert overwrite table $APP.ads_category_retention
select '$do_date' dt,
        category_id,
        category_name,
       recent_days,
       sum(order_person_count) order_person_count,
       sum(first_start_person_count) first_start_person_count,
       avg(category_retention_rate) category_retention_rate
from
(select dc.category_id,
        category_name,
        order_person_count,
        first_start_person_count,
        (order_person_count/first_start_person_count) category_retention_rate,
        dt
from $APP.dws_course_course_videofirst_1d dc
left join (
    select category_id,
           category_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by category_id, category_name
    )dim
on dc.category_id = dim.category_id
    )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by category_id, category_name, recent_days;
"
ads_subject_retention="
insert overwrite table $APP.ads_subject_retention
select '$do_date' dt,
        subject_id,
        subject_name,
       recent_days,
       sum(order_person_count) order_person_count,
       sum(first_start_person_count) first_start_person_count,
       avg(category_retention_rate) category_retention_rate
from
(select dc.subject_id,
        subject_name,
        order_person_count,
        first_start_person_count,
        (order_person_count/first_start_person_count) category_retention_rate,
        dt
from $APP.dws_course_course_videofirst_1d dc
left join (
    select subject_id,
           subject_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by subject_id, subject_name
    )dim
on dc.subject_id = dim.subject_id
    )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by subject_id, subject_name, recent_days;
"
ads_course_order="
insert overwrite table $APP.ads_course_retention
select '$do_date' dt,
        course_id,
        course_name,
       recent_days,
       sum(order_person_count) order_person_count,
       sum(first_start_person_count) first_start_person_count,
       avg(category_retention_rate) category_retention_rate
from
(select dc.course_id,
        course_name,
        order_person_count,
        first_start_person_count,
        (order_person_count/first_start_person_count) category_retention_rate,
        dt
from $APP.dws_course_course_videofirst_1d dc
left join (
    select id,
           course_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by id, course_name
    )dim
on dc.course_id = dim.id
    )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by course_id, course_name, recent_days;
"
ads_order_all="
insert overwrite table $APP.ads_order_all
select '$do_date' dt,
       recent_days,
       sum(order_count_1d) order_count,
       sum(order_person_count_1d) order_people_count,
       sum(order_amounts_1d) order_total_amount
from $APP.dws_course_order_province_1d
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days;
"
ads_order_by_province="
insert overwrite table $APP.ads_order_by_province
select '$do_date' dt,
       recent_days,
       province_id,
       province_name,
       area_code,
       iso_code,
       iso_3166_2,
       sum(order_count_1d) order_count,
       sum(order_person_count_1d) order_people_count,
       sum(order_amounts_1d) order_total_amount
from $APP.dws_course_order_province_1d
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days,province_id,province_name,area_code,iso_code,iso_3166_2;
"
ads_exam_avg="
insert overwrite table $APP.ads_exam_avg
   select '$do_date' dt,
          recent_days,
          paper_id,
          paper_title,
          avg(avgscore) avgscore,
          avg(avgtime) avgtime,
          sum(user_count)
   from
   (
       select de.paper_id,
          paper_title,
          (score_sum/user_count) avgscore,
          (end_time_sum/user_count) avgtime,
          user_count,
          dt
   from $APP.dws_exam_course_sum_1d de
   left join
   (
    select paper_id,paper_title
    from $APP.dim_paper_full
    where dt = '$do_date'
    group by paper_id,paper_title
    ) dim
    on dim.paper_id = de.paper_id
       )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days,paper_id,paper_title;
"
ads_exam_course_avg="
insert overwrite table $APP.ads_exam_course_avg
   select '$do_date' dt,
          recent_days,
          course_id,
          course_name,
          avg(avgscore) avgscore,
          avg(avgtime) avgtime,
          sum(user_count)
   from
   (
       select de.course_id,
          course_name,
          (score_sum/user_count) avgscore,
          (end_time_sum/user_count) avgtime,
          user_count,
          dt
   from $APP.dws_exam_course_sum_1d de
   left join
   (
    select id,course_name
    from $APP.dim_course_full
    where dt = '$do_date'
    group by id,course_name
    ) dim
    on dim.id = de.course_id
       )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days,course_id,course_name;
"
ads_exam_score_distribution="
insert overwrite table $APP.ads_exam_score_distribution
select '$do_date' dt,
       recent_days,
       paper_id,
       paper_title,
       sum(scoredistributionwangzhe),
       sum(scoredistributionyouxiu),
       sum(scoredistributionlianghao),
       sum(scoredistributionjige),
       sum(scoredistributionbujige)
from
    (
       select de.paper_id,
              paper_title,
              scoredistributionwangzhe,
              scoredistributionyouxiu,
              scoredistributionlianghao,
              scoredistributionjige,
              scoredistributionbujige,
               dt
   from $APP.dws_exam_score_distribution_1d de
   left join
   (
    select paper_id,paper_title
    from $APP.dim_paper_full
    where dt = '$do_date'
    group by paper_id,paper_title
    ) dim
    on dim.paper_id = de.paper_id
       )t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days,paper_id,paper_title;
"
ads_exam_question_sum="
insert overwrite table $APP.ads_exam_question_sum
select '$do_date' dt,
       recent_days,
       question_id,
       question_txt,
       avg(accracyRate) accracyRate
from
(
    select dt,
           da.question_id,
           question_txt,
           (correct_sum / question_sum) accracyRate
    from $APP.dws_exam_question_sum_1d da
             left join (
        select question_id,
               question_txt
        from $APP.dim_paper_full
        where dt = '$do_date'
        group by question_id, question_txt
    ) dim
        on dim.question_id = da.question_id
)t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days,question_id,question_txt;
"
ads_chapter_video_play="
insert overwrite table $APP.ads_chapter_video_play
select '$do_date' dt,
       recent_days,
       chapter_id,
       chapter_name,
       sum(video_play_count) video_play_count,
       avg(video_play_time_avg) video_play_time_avg,
       sum(video_watch_person_count) video_watch_person_count
from
(
    select dp.chapter_id,
       chapter_name,
       video_play_count,
       (video_play_time_sum/video_watch_person_count) video_play_time_avg,
       video_watch_person_count,
       dt
from $APP.dws_play_course_playvideo_1d dp
left join(
    select
       chapter_id,
       chapter_name
from $APP.dim_video_full
where dt = '$do_date'
group by chapter_id,chapter_name
) dim
on dp.chapter_id = dim.chapter_id
    ) t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days,chapter_id,chapter_name;
"
ads_course_video_play="
insert overwrite table $APP.ads_course_video_play
select '$do_date' dt,
       recent_days,
       course_id,
       course_name,
       sum(video_play_count) video_play_count,
       avg(video_play_time_avg) video_play_time_avg,
       sum(video_watch_person_count) video_watch_person_count
from
(
    select dp.course_id,
       course_name,
       video_play_count,
       (video_play_time_sum/video_watch_person_count) video_play_time_avg,
       video_watch_person_count,
       dt
from $APP.dws_play_course_playvideo_1d dp
left join(
    select
       id,
       course_name
from $APP.dim_course_full
where dt = '$do_date'
group by id,course_name
) dim
on dp.course_id = dim.id
    ) t
lateral view explode(array(1,7,30)) tmp as recent_days
where dt >= date_sub('$do_date',recent_days-1)
group by  recent_days,course_id,course_name;
"
ads_course_completed="
insert overwrite table $APP.ads_course_completed
select
       '$do_date' dt,
       recent_days,
       course_id,
       course_name,
       sum(if(course_completed_person_count >= chapter_num,1 , 0))course_completed_person_count
from
(
select
    user_id,
    recent_days,
    course_id,
    sum(if(video_play_sec>=video_size*0.1 and video_position_sec>=video_size*0.1,1,0)) course_completed_person_count
from $APP.dws_play_course_userplayend_1d
lateral view explode(array(1,7,30)) tmp as recent_days
where dt>=date_sub('$do_date',recent_days-1)
group by user_id,course_id,recent_days
)t1
left join
(
select
    id,
    course_name,
     max(chapter_num) chapter_num
from $APP.dim_course_full
where dt='$do_date'
group by id,course_name
)t2
on t1.course_id=t2.id
group by course_id,course_name,recent_days;
"
ads_all_completed="
insert overwrite table $APP.ads_all_completed
select '$do_date' dt,
       t3.recent_days,
       all_completed_person_count,
       all_completed_person
from
(
    select recent_days,
           sum(if(course_completed_person_count >= chapter_num, 1, 0)) all_completed_person_count
    from (
             select user_id,
                    recent_days,
                    course_id,
                    sum(if(video_play_sec >= video_size * 0.1 and video_position_sec >= video_size * 0.1, 1,
                           0)) course_completed_person_count
             from $APP.dws_play_course_userplayend_1d dp
                      lateral view explode(array(1, 7, 30)) tmp as recent_days
             where dt >= date_sub('$do_date', recent_days - 1)
             group by user_id, course_id, recent_days
         ) t1
             left join
         (
             select id,
                    course_name,
                    max(chapter_num) chapter_num
             from $APP.dim_course_full
             where dt = '$do_date'
             group by id, course_name
         ) t2
         on t1.course_id = t2.id
    group by recent_days
)t3 left join(
select

       recent_days,
       sum(if(course_completed_person_count >= chapter_num,1 , 0)) all_completed_person
from
(
select
    user_id,
    recent_days,
    course_id,
    sum(if(video_play_sec>=video_size*0.1 and video_position_sec>=video_size*0.1,1,0)) course_completed_person_count
from $APP.dws_play_course_userplayend_1d dp
lateral view explode(array(1,7,30)) tmp as recent_days
where dt>=date_sub('$do_date',recent_days-1)
group by user_id,course_id,recent_days
)t1
left join
(
select
    id,
    course_name,
    max(chapter_num) chapter_num
from $APP.dim_course_full
where dt='$do_date'
group by id,course_name
)t2
on t1.course_id=t2.id
group by recent_days,user_id
) t4
on t3.recent_days = t4.recent_days;
"


case $1 in
"ads_user_change")
hive -e "$ads_user_change"
;;
"ads_user_retention")
hive -e "$ads_user_retention"
;;
"ads_user_stats")
hive -e "$ads_user_stats"
;;
"ads_user_action")
hive -e "$ads_user_action"
;;
"ads_new_buyer_stats")
hive -e "$ads_new_buyer_stats"
;;
"ads_course_completed")
    hive -e "$ads_course_completed"
;;
"ads_all_completed")
    hive -e "$ads_all_completed"
;;
"ads_course_video_play")
    hive -e "$ads_course_video_play"
;;
"ads_chapter_video_play")
    hive -e "$ads_chapter_video_play"
;;
"ads_exam_question_sum")
    hive -e "$ads_exam_question_sum"
;;
"ads_exam_score_distribution")
    hive -e "$ads_exam_score_distribution"
;;
"ads_exam_course_avg")
    hive -e "$ads_exam_course_avg"
;;
"ads_exam_avg")
    hive -e "$ads_exam_avg"
;;
"ads_order_by_province")
    hive -e "$ads_order_by_province"
;;
"ads_order_all")
    hive -e "$ads_order_all"
;;
"ads_subject_retention")
    hive -e "$ads_subject_retention"
;;
"ads_course_retention")
    hive -e "$ads_course_retention"
;;
"ads_category_retention")
    hive -e "$ads_category_retention"
;;
"ads_process_user_review_by_course")
    hive -e "$ads_process_user_review_by_course"
;;
"ads_course_order")
    hive -e "$ads_course_order"
;;
"ads_subject_order")
    hive -e "$ads_subject_order"
;;
"ads_category_order")
    hive -e "$ads_category_order"
;;
"ads_age_order")
    hive -e "$ads_age_order"
;;
"ads_source_ordersum")
    hive -e "$ads_source_ordersum"
;;
"ads_page_path")
    hive -e "$ads_page_path"
;;
"ads_traffic_stats_by_source")
    hive -e "$ads_traffic_stats_by_source"
;;
"all")
    hive -e "$ads_user_change$ads_user_retention$ads_user_stats$ads_user_action$ads_new_buyer_stats$ads_traffic_stats_by_source$ads_page_path$ads_source_ordersum$ads_age_order$ads_category_order$ads_subject_order$ads_course_order$ads_process_user_review_by_course$ads_category_retention$ads_subject_retention$ads_course_retention$ads_order_all$ads_order_by_province$ads_exam_avg$ads_exam_course_avg$ads_exam_score_distribution$ads_exam_question_sum$ads_chapter_video_play$ads_course_video_play$ads_course_completed$ads_all_completed"
;;
esac
